home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / mail / pine3.96.tar.gz / pine3.96.tar / pine3.96 / pine / osdep / fnexpand.os2 < prev    next >
Text File  |  1996-03-14  |  896b  |  34 lines

  1. #line 2 "osdep/fnexpand.os2"
  2. /*----------------------------------------------------------------------
  3.        Expand the ~ in a file ala the csh (as home directory)
  4.  
  5.    Args: buf --  The filename to expand (nothing happens unless begins with ~)
  6.          len --  The length of the buffer passed in (expansion is in place)
  7.  
  8.  Result: Expanded string is returned using same storage as passed in.
  9.          If expansion fails, NULL is returned
  10.  ----*/
  11. char *
  12. fnexpand(buf, len)
  13.     char *buf;
  14.     int len;
  15. {
  16.     register char *x,*y;
  17.     char * home;
  18.     char name[20];
  19.     char * gethomedir();
  20.     
  21.     if(*buf == '~') {
  22.         home=gethomedir();
  23.         for(x = buf+1, y = name; *x != '/' && *x != '\0'; *y++ = *x++);
  24.         *y = '\0';
  25.         if(strlen(home) + strlen(buf) > len) {
  26.           return((char *)NULL);
  27.         }
  28.         rplstr(buf, x - buf, home);
  29.     }
  30.     return(len ? buf : (char *)NULL);
  31. }
  32.  
  33.  
  34.